import { ImageProps } from "@tarojs/components";
import { Image } from "@tarojs/components";
import Taro from "@tarojs/taro";
import { getImg } from "@/utils";

const ImagePreview = (props: ImageProps) => {
  const img = getImg(props.src);

  const handlePrevImage = () => {
    Taro.previewImage({
      urls: [img],
      current: img,
    });
  };

  return <Image {...props} onClick={handlePrevImage} />;
};

export default ImagePreview;
